*November 16, 2025
**Wilk, Deza, Hodge, Danagoulian (2025) Couch-Locked with the Munchies: Effects of Recreational Marijuana Laws on Exercise and Nutrition
**This code creates the following: 
*From main paper: Tables 7 and Figures 3
*From Online Appendix: Table A2-A5-A8-A11-A14

***************************************************
*These tables and figures can be used after downloading the following
*~/Dropbox/Medical_Marijuana_Laws/Data/atus/atus_raw.dta"
*"~/Dropbox/Medical_Marijuana_Laws/Data/controls_cdcdatawonder.dta"
**************************************************
	clear
	use "~/Dropbox/Medical_Marijuana_Laws/Data/atus/atus_raw.dta"
	*Data is unique by person-activity-start time 
		bysort caseid pernum activity start: gen n=_N
		assert n==1
		drop n 
	*Sex
		gen male=(sex==1)
	*Race
		gen white=(race==100)
		gen black=(race==110)		
	**Hispanic
		gen hispanic=(hispan!=100)
	**Weight is missing 2006 but then it is assigned in 2020
		gen weight=wt06 
		replace weight=wt20 if weight==.
		assert weight!=.
	**Place: 
		*Driver or passenger of car, truck, or motorcycle
			gen where_car=(where==230|where==231)
		**Walking 
			gen where_walking=(where==232)
		**Public Transit: Bus, train, subway, ferry
			gen where_publictransit=(where==233|where==234|where==236)
		**Bycicle
			gen where_bike=(where==235)
		*R's home or yard
			gen where_home=(where==101)
		*Gym/health club
			gen where_gym=(where==112)
		**Grocery store
			gen where_grocerystore=(where==106)
		**Restaurant or bar
			gen where_restbar=(where==104)
		**School 
			gen where_school=(where==108)
		**R's workplace
			gen where_workplace=(where==102)
		**Someone else's home
			gen where_otherpplhome=(where==103)
		**Outdoors
			gen where_outdoors=(where==109)
		**Other indoors. 
		*0105 `"Place of worship"'
		*0107 `"Other store/mall"'
		*0109 `"Outdoors--not at home"'
		*0110 `"Library"'
		*0111 `"Bank"'
		*0113 `"Post Office"'
		*0114 `"Other place"'
			gen where_otherindoortran=(where==105|where==107|where==110|where==111|where==113|where==114|where==237|where==238|where==239|where==240)

		**Unspecified place:115
		**dont know: 9997
		**refused:9998
		**NIU: not in universe: 9999
			gen where_unspecified=(where==115)
			gen where_niu=(where==9999)
			gen where_compmissing=(where==115|where==9997|where==9998|where==9999)		
	**Make sure R reports one place at a time 
		gen timepltot=where_home+where_gym+where_grocerystore+where_restbar+where_school+where_workplace+where_outdoors+where_otherpplhome+where_compmissing+where_car+where_walking+where_publictransit+where_bike+where_otherindoortran
		assert timepltot==1
	
	***********************************************************
	**Duration of time spent in each place
	***********************************************************	
		gen timeplace_car=duration if where_car==1
		gen timeplace_walking=duration if where_walking==1
		gen timeplace_publictransit=duration if where_publictransit==1
		gen timeplace_bike=duration if where_bike==1
		gen timeplace_home=duration if where_home==1
		gen timeplace_gym=duration if where_gym==1
		gen timeplace_grocerystore=duration if where_grocerystore==1
		gen timeplace_restbar=duration if where_restbar==1
		gen timeplace_school=duration if where_school==1
		gen timeplace_workplace=duration if where_workplace==1
		gen timeplace_otherpplhome=duration if where_otherpplhome==1
		gen timeplace_outdoors=duration if where_outdoors==1
		gen timeplace_unspecified=duration if where_unspecified==1
		gen timeplace_niu=duration if where_niu==1
		gen timeplace_compmissing=duration if where_compmissing==1
		gen timeplace_othindoor=duration if where_otherindoortran==1

	******************************************
	**Collapse, and make sure time adds to 1440
	*****************************************
		local list_time_activities="timeplace_car timeplace_walking timeplace_publictransit timeplace_bike timeplace_home timeplace_gym timeplace_grocerystore timeplace_restbar timeplace_school timeplace_workplace timeplace_otherpplhome timeplace_outdoors timeplace_unspecified timeplace_niu timeplace_compmissing timeplace_othindoor"	
	collapse (sum) `list_time_activities' (mean) male white black hispanic weight statefip month year age, by(caseid pernum)
	gen timepltot=timeplace_car+timeplace_walking+timeplace_publictransit+timeplace_bike+timeplace_home+timeplace_gym+timeplace_grocerystore+timeplace_restbar+timeplace_school+timeplace_workplace+timeplace_otherpplhome+timeplace_outdoors+timeplace_compmissing+timeplace_othindoor
	assert timepltot==1440

****************************************************************
**Merge controls 
************************************************************
	rename statefip statefips 
	sum year 
	merge m:m year statefip using "~/Dropbox/Medical_Marijuana_Laws/Data/controls_cdcdatawonder.dta"
	keep if _merge==3
	drop _merge

******************************
**DATES for MML and RML start sales
*******************************
	gen mml_start=.
	gen rml_start=.
	gen month_mml_start=. 
	gen month_rml_start=. 
	*Alabama 
	*Alaska, MML sales start: N/A, RML sales start 10/29/2016
		replace rml_start=2016 if statefips==2	
		replace month_rml_start=10 if statefips==2		
	*Arizona, MML sales start 12/06/2012, RML sales start 1/22/2021
		replace mml_start=2012 if statefips==4
		replace rml_start=2021 if statefips==4	
		replace month_mml_start=12 if statefips==4
		replace month_rml_start=1 if statefips==4
	*Arkansas, MML sales start 05/11/2019, RML sales start (-)
		replace mml_start=2019 if statefips==5
		replace month_mml_start=5 if statefips==5	
	*California, MML sales start: 01/01/2018, RML sales start: 1/1/2018
		replace mml_start=2018 if statefips==6
		replace rml_start=2018 if statefips==6
		replace month_mml_start=1 if statefips==6
		replace month_rml_start=1 if statefips==6
	**Colorado, MML sales start: 10/26/2011, RML sales start: 1/1/2014
		replace mml_start=2011 if statefips==8
		replace rml_start=2014 if statefips==8
		replace month_mml_start=10 if statefips==8
		replace month_rml_start=1 if statefips==8
	*Connecticut, MML sales start: 08/20/2014, RML sales start: 1/10/2023
		replace mml_start=2014 if statefips==9
		replace rml_start=2023 if statefips==9
		replace month_mml_start=8 if statefips==9
		replace month_rml_start=1 if statefips==9
	*Delaware, MML sales start: 06/26/2015, RML sales start: 2024
		replace mml_start=2015 if statefips==10
		replace rml_start=. if statefips==10
		replace month_mml_start=6 if statefips==10
		replace month_rml_start=. if statefips==10
	*DC, MML sales start: 07/30/2013, RML sales start: 2/26/2015
		replace mml_start=2013 if statefips==11
		replace rml_start=2015 if statefips==11
		replace month_mml_start=7 if statefips==11
		replace month_rml_start=2 if statefips==11
	*Florida, MML sales start: 07/26/2016, RML sales start:(-)
		replace mml_start=2016 if statefips==12
		replace month_mml_start=7 if statefips==12
	*Georgia (n/a)
	**Hawaii, MML sales start: 08/08/2017, RML sales start: (-)
		replace mml_start=2017 if statefips==15
		replace month_mml_start=8 if statefips==15
	**Idaho (N/A)
	**Illinois, MML sales start:11/09/2015, RML sales start: 1/1/2020
		replace mml_start=2015 if statefips==17
		replace rml_start=2020 if statefips==17
		replace month_mml_start=11 if statefips==17
		replace month_rml_start=1 if statefips==17
	*Indiana (N/A)
	*Iowa (N/A)
	*Kansas (N/A)
	*Kentucky (n/a until 2025)
	*Louisiana, MML sales start:08/06/2019, RML sales start:(-)
		replace mml_start=2019 if statefips==22
		replace month_mml_start=8 if statefips==22
	*Maine, MML sales start: 03/2011, RML sales start: 10/9/2020
		replace mml_start=2011 if statefips==23
		replace rml_start=2020 if statefips==23
		replace month_mml_start=3 if statefips==23
		replace month_rml_start=10 if statefips==23
	*Maryland, MML sales start: 12/01/2017, RML sales start: 7/1/2023
		replace mml_start=2017 if statefips==24
		replace rml_start=2023 if statefips==24
		replace month_mml_start=12 if statefips==24
		replace month_rml_start=7 if statefips==24
	*Massachusetts, MML sales start: 06/24/2015, RML sales start: 11/20/2018
		replace mml_start=2015 if statefips==25
		replace rml_start=2018 if statefips==25
		replace month_mml_start=6 if statefips==25
		replace month_rml_start=11 if statefips==25	
	*Michigan, MML sales start: 08/2018, RML sales start: 12/1/2019
		replace mml_start=2018 if statefips==26
		replace rml_start=2019 if statefips==26
		replace month_mml_start=8 if statefips==26
		replace month_rml_start=12 if statefips==26
	*Minnesota, MML sales start: 7/1/2015, RML sales start: (-)
		replace mml_start=2015 if statefips==27
		replace month_mml_start=7 if statefips==27
	**Mississippi, MML sales start: 1/25/23, RML sales start: (-)
		replace mml_start=2023 if statefips==28
		replace month_mml_start=1 if statefips==28
	*Missouri, MML sales start: 10/17/20, RML sales start: 2/3/23
		replace mml_start=2020 if statefips==29
		replace rml_start=2023 if statefips==29
		replace month_mml_start=10 if statefips==29
		replace month_rml_start=2 if statefips==29
	*Montana, MML sales start: 4/1/2018, RML sales start: 1/1/2022
		replace mml_start=2018 if statefips==30
		replace rml_start=2022 if statefips==30
		replace month_mml_start=4 if statefips==30
		replace month_rml_start=1 if statefips==30
	*Nebraska (N/a)
	*Nevada, MML sales start: 7/31/2015, RML sales start: 7/1/2017
		replace mml_start=2015 if statefips==32
		replace rml_start=2017 if statefips==32	
		replace month_mml_start=7 if statefips==32
		replace month_rml_start=1 if statefips==32
	*New Hampshire, MML sales start: 5/1/2016, RML sales start:(-)
		replace mml_start=2016 if statefips==33
		replace month_mml_start=5 if statefips==33
	*New Jersey , MML sales start: 12/6/2012, RML sales start: 4/20/2022
		replace mml_start=2012 if statefips==34
		replace rml_start=2022 if statefips==34
		replace month_mml_start=12 if statefips==2012
		replace month_rml_start=4 if statefips==2022
	*New MExico, MML sales start: 1/1/2010, RML sales start: 4/1/2022
		replace mml_start=2010 if statefips==35
		replace rml_start=2022 if statefips==35
		replace month_mml_start=1 if statefips==35
		replace month_rml_start=4 if statefips==35
	*New York, MML sales start: 1/7/2016, RML sales start: 12/29/22
		replace mml_start=2016 if statefips==36
		replace rml_start=2022 if statefips==36	
		replace month_mml_start=1 if statefips==36
		replace month_rml_start=12 if statefips==36
	*North Carolina (N/a)
	*North Dakota. MML sales start: 3/1/2019, RML sales start:(-)
		replace mml_start=2019 if statefips==38
		replace month_mml_start=3 if statefips==38
	*Ohio, MML sales start: 1/16/2019, RML sales start: (-)
		replace mml_start=2019 if statefips==39
		replace month_mml_start=1 if statefips==39
	*Oklahoma, MML sales start: 10/26//2018, RML sales start: (-)
		replace mml_start=2018 if statefips==40
		replace month_mml_start=10 if statefips==40
	*Oregon, MML sales start: 3/21/2014, RML sales start: 10/1/15
		replace mml_start=2014 if statefips==41
		replace rml_start=2015 if statefips==41
		replace month_mml_start=3 if statefips==41
		replace month_rml_start=10 if statefips==41
	*Pennsylvania, MML sales start: 2/15/2018, RML sales start: (-)
		replace mml_start=2018 if statefips==42
		replace month_mml_start=2 if statefips==42
	*Rhode Island, MML sales start: 4/19/2013, RML sales start: 12/1/2022
		replace mml_start=2013 if statefips==44
		replace rml_start=2022 if statefips==44
		replace month_mml_start=4 if statefips==44
		replace month_rml_start=12 if statefips==44
	*South Carolina : n/a	
	**South Dakota, MML sales start: 7/27/2022, RML sales start :(-)
		replace mml_start=2022 if statefips==46
		replace month_mml_start=7 if statefips==46
	*Tennessee (n/a)
	*Texas (n/a)	
	*Utah, MML sales start: 3/2/20, RML sales start: (-)
		replace mml_start=2020 if statefips==49
		replace month_mml_start=3 if statefips==49
	*Vermont, MML sales start: 6/25/2013, RML sales start: 10/1/2022
		replace mml_start=2013 if statefips==50
		replace rml_start=2022 if statefips==50
		replace month_mml_start=6 if statefips==50
		replace month_rml_start=10 if statefips==50
	*Virginia, MML sales start: 10/17/2020, RML sales start: (-)
		replace mml_start=2020 if statefips==51
		replace month_mml_start=10 if statefips==51
	*Washington, MML sales start: 7/8/2014, RML sales start: 7/8/14
		replace mml_start=2014 if statefips==53
		replace rml_start=2014 if statefips==53
		replace month_mml_start=7 if statefips==53
		replace month_rml_start=7 if statefips==53
	*West Virginia, MML sales start: 11/12/2021, RML sales start (-)
		replace mml_start=2021 if statefips==54
		replace month_mml_start=11 if statefips==54
	*Wisconsin : N/A
	*Wyoming : N/A/ 

*******************************
*Period 1 and Period 2
*******************************
	*Years where the entire year has the policy or not
		gen period1_start=(year>mml_start & year<rml_start) if mml_start!=. & rml_start!=.
		gen period2_start=(year>rml_start) if mml_start!=. & rml_start!=.
	
		replace period1_start=(year>mml_start) if mml_start!=. & rml_start==.
		replace period2_start=0 if mml_start!=. & rml_start==.
		
		replace period1_start=0 if mml_start==. & rml_start!=.
		replace period2_start=(year>rml_start) if mml_start==. & rml_start!=.
	
		replace period1_start=0 if mml_start==. & rml_start==.
		replace period2_start=0 if mml_start==. & rml_start==.

	**Year of implementation 
		replace period1_start=1 if month>=month_mml_start & year==mml_start & mml_start!=. & month_mml_start!=.
		replace period1_start=0 if month<month_mml_start & year==mml_start & mml_start!=. & month_mml_start!=.
	
		replace period2_start=1 if month>=month_rml_start & year==rml_start & rml_start!=. & month_rml_start!=.
		replace period2_start=0 if month<month_rml_start & year==rml_start & rml_start!=. & month_rml_start!=.

**************************************
**Covid dummies for controlling for stay at home orders
**ATUS does not have April 2020 
*Month is marked as covid month if at least 7 days of the month
***************************************
	assert month!=4 if year==2020
	gen covid=0
	replace covid=1 if month==4 & year==2020 & statefips==1
	replace covid=1 if (month==4) & year==2020 & statefips==2
	replace covid=1 if (month==4|month==5) & year==2020 & statefips==4
	replace covid=1 if ((month>=4 & year>=2020)|(month==1 & year==2021)) & statefips==6
	replace covid=1 if (month==4) & year==2020 & statefips==8
	replace covid=1 if (month==3|month==4|month==5) & year==2020 & statefips==9
	replace covid=1 if (month==3|month==4|month==5) & year==2020 & statefips==10
	replace covid=1 if (month==4|month==5) & year==2020 & statefips==11
	replace covid=1 if (month==4|month==5) & year==2020 & statefips==12
	replace covid=1 if (month==4) & year==2020 & statefips==13
	replace covid=1 if (month==3|month==4|month==5) & year==2020 & statefips==15
	replace covid=1 if (month==3|month==4) & year==2020 & statefips==16
	replace covid=1 if (month==3|month==4|month==5) & year==2020 & statefips==17
	replace covid=1 if (month==3|month==4|month==5) & year==2020 & statefips==18
	replace covid=1 if (month==4) & year==2020 & statefips==20
	replace covid=1 if (month==4|month==5|month==6) & year==2020 & statefips==21
	replace covid=1 if (month==3|month==4|month==5) & year==2020 & statefips==22
	replace covid=1 if (month==4|month==5) & year==2020 & statefips==23
	replace covid=1 if (month==4|month==5) & year==2020 & statefips==24
	replace covid=1 if (month==3|month==4|month==5) & year==2020 & statefips==25
	replace covid=1 if (month==3|month==4|month==5) & year==2020 & statefips==26
	replace covid=1 if (month==4|month==5) & year==2020 & statefips==27
	replace covid=1 if (month==4) & year==2020 & statefips==28 
	replace covid=1 if (month==4) & year==2020 & statefips==29
	replace covid=1 if (month==4) & year==2020 & statefips==30
	replace covid=1 if (month==4) & year==2020 & statefips==32
	replace covid=1 if (month==4|month==5|month==6) & year==2020 & statefips==33
	replace covid=1 if (month==3|month==4|month==5|month==6) & year==2020 & statefips==34
	replace covid=1 if (month>=3 & month<=11) & year==2020 & statefips==35
	replace covid=1 if (month>=3 & month<=6) & year==2020 & statefips==36
	replace covid=1 if (month==4|month==5) & year==2020 & statefips==37
	replace covid=1 if (month==3|month==4|month==5) & year==2020 & statefips==39
	replace covid=1 if (month==4|month==5) & year==2020 & statefips==40
	replace covid=1 if (month>=3 & month<=6) & year==2020 & statefips==41
	replace covid=1 if (month==4|month==5) & year==2020 & statefips==42
	replace covid=1 if (month==4|month==5) & year==2020 & statefips==44
	replace covid=1 if (month==4) & year==2020 & statefips==45
	replace covid=1 if month==4 & year==2020 & statefips==47 
	replace covid=1 if month==4 & year==2020 & statefips==48
	replace covid=1 if (month>=3 & month<=5) & year==2020 & statefips==50
	replace covid=1 if (month>=4 & month<=5) & year==2020 & statefips==51
	replace covid=1 if (month>=3 & month<=5) & year==2020 & statefips==53
	replace covid=1 if (month==3|month==4) & year==2020 & statefips==54
	replace covid=1 if (month>=3 & month<=5) & year==2020 & statefips==55

**Timing Variable:
		sort year month
		egen yearmonth=group(year month)

	**CSDID Groupvar for csdid AND FOR DID_INFERENCE 
		sort year month 
		*GVAR
		gen groupvar=0	
		*fips=2 (october 2016)
		replace groupvar=142 if statefips==2 
		**fips 4 all 2021+			
		replace groupvar=192 if statefips==4 
		**fips 5 all 2018+	
		replace groupvar=157 if statefips==6 
		**fips 8 all 2014+
		replace groupvar=109 if statefips==8 
		**fips 9 all 2023+
		**fips 10 all 2024+
		**fips 11 feb 2015
		replace groupvar=122 if statefips==11 
		**fips 17 2020plus
		replace groupvar=181 if statefips==17 
		*fips 23 oct 2020
		replace groupvar=189 if statefips==23 
		*fips 24 july 2023
		*fips 25 november 2018
		replace groupvar=167 if statefips==25 
		*fips 26 dec 2019
		replace groupvar=180 if statefips==26 
		*fips 29 , 2023+
		*fips 30, 2022+
		*fips 32, july 2017
		replace groupvar=151 if statefips==32 
		*fips 34, 2022
		*fips 36, 2022
		*fips 41, oct 2015
		replace groupvar=130 if statefips==41 
		*fips 44, 2022+
		*fips 50, 2022+
		*fips 53, july 2014
		replace groupvar=115 if statefips==53 
		
***********************************************
**Share of non missing day spent on each place
**********************************************
	gen timenonmisspl=timeplace_car+timeplace_walking+timeplace_publictransit+timeplace_bike+timeplace_home+timeplace_gym+timeplace_grocerystore+timeplace_restbar+timeplace_school+timeplace_workplace+timeplace_otherpplhome+timeplace_outdoors+timeplace_othindoor

	gen share_home=(timeplace_home/timenonmisspl)*100
	gen share_gym=(timeplace_gym/timenonmisspl)*100
	gen share_grocerystore=(timeplace_grocerystore/timenonmisspl)*100
	gen share_restbar=(timeplace_restbar/timenonmisspl)*100
	gen share_school=(timeplace_school/timenonmisspl)*100
	gen share_workplace=(timeplace_workplace/timenonmisspl)*100
	gen share_otherpplhome=(timeplace_otherpplhome/timenonmisspl)*100
	gen share_outdoors=(timeplace_outdoors/timenonmisspl)*100
tempfile atus 
save "`atus'"

**********************************************
**Table 7: ATUS BJS 
*********************************************
	clear 
	use "`atus'"
	keep if year>=2011 & year<=2021
	keep if age>=21 & age!=.
	
	**BJS 
		rename groupvar Ei
		replace Ei=. if Ei==0
	**BJS FE 
		local bjs_controls0="period1_start statefips year"
		local bjs_controls1="month age covid  male period1_start statefips year"
	**Regression 
		foreach y in "timeplace_home" "timeplace_gym" "timeplace_grocerystore" "timeplace_restbar"  "timeplace_workplace" "timeplace_outdoors" "timeplace_compmissing"{
			**All, Basis 
			dis "outcome `y', controls0"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight], fe(`bjs_controls0')  cluster(statefips) autosample	
			sum `y' [aw=weight] if e(sample)==1
			 
			**All, Full FE 
			dis "outcome `y', controls1"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight], fe(`bjs_controls1') cluster(statefips) autosample
			sum `y' [aw=weight] if e(sample)==1
			
			**Male, Basis 
			dis "outcome `y', controls0"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if male==1, fe(`bjs_controls0')  cluster(statefips) autosample	
			sum `y' [aw=weight] if e(sample)==1
			 
			**Male, Full FE 
			dis "outcome `y', controls1"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if male==1, fe(`bjs_controls1') cluster(statefips) autosample
			sum `y' [aw=weight] if e(sample)==1
			
			**Female, Basis 
			dis "outcome `y', controls0"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if male==0, fe(`bjs_controls0')  cluster(statefips) autosample	
			sum `y' [aw=weight] if e(sample)==1
			 
			**Female, Full FE 
			dis "outcome `y', controls1"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if male==0, fe(`bjs_controls1') cluster(statefips) autosample
			sum `y' [aw=weight] if e(sample)==1
	}

**********************************************************
**Table A2: ATUS by age 
********************************************************
	clear 
	use "`atus'"
	keep if year>=2011 & year<=2021
	keep if age>=21 & age!=.
	
	**BJS 
		rename groupvar Ei
		replace Ei=. if Ei==0
	**BJS FE 
		local bjs_controls1="month age covid  male period1_start statefips year"
	**Regression 
		foreach y in "timeplace_home" "timeplace_gym" "timeplace_grocerystore" "timeplace_restbar"  "timeplace_workplace" "timeplace_outdoors" "timeplace_compmissing"{
			**Age 21-24, Full FE 
			dis "outcome `y', controls1"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if age>=21 & age<=24, fe(`bjs_controls1') cluster(statefips) autosample
			sum `y' [aw=weight] if e(sample)==1
						 
			**Age 25-39, Full FE 
			dis "outcome `y', controls1"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if age>=25 & age<=39, fe(`bjs_controls1') cluster(statefips) autosample
			sum `y' [aw=weight] if e(sample)==1
				 
			**Age 40+, Full FE 
			dis "outcome `y', controls1"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if age>=40 & age!=., fe(`bjs_controls1') cluster(statefips) autosample
			sum `y' [aw=weight] if e(sample)==1
			}

**************************************************
**Table A5: Gardner and TWFE
************************************************
	clear 
	use "`atus'"
	keep if year>=2011 & year<=2021
	keep if age>=21 & age!=.

	**Controls
		local controls2="i.month i.age i.covid  i.male i.period1_start i.statefips i.year"
		local cont_controls="blackshare maleshare age1825share"

	foreach y in "timeplace_home" "timeplace_gym" "timeplace_grocerystore" "timeplace_restbar" "timeplace_workplace" "timeplace_otherpplhome" "timeplace_outdoors"  {	
		**All, TWFE
			eststo :reg `y' period2_start `controls2' `cont_controls' [aw=weight], cluster(statefip)
			sum `y' [aw=weight] if e(sample)==1
		**All, GARDNER 				
			eststo :did2s `y'  [aw=weight], first_stage(`controls2') second_stage(period2_start) treatment(period2_start) cluster(statefip)
			sum `y' [aw=weight] if e(sample)==1
		**Male, TWFE
			eststo :reg `y' period2_start `controls2' `cont_controls' [aw=weight] if male==1, cluster(statefip)
			sum `y' [aw=weight] if e(sample)==1
		**Male, GARDNER 				
			eststo :did2s `y'  [aw=weight] if male==1, first_stage(`controls2') second_stage(period2_start) treatment(period2_start) cluster(statefip)
			sum `y' [aw=weight] if e(sample)==1
		**Female, TWFE
			eststo :reg `y' period2_start `controls2' `cont_controls' [aw=weight] if male==0, cluster(statefip)
			sum `y' [aw=weight] if e(sample)==1
		**Female, GARDNER 				
			eststo :did2s `y'  [aw=weight] if male==0, first_stage(`controls2') second_stage(period2_start) treatment(period2_start) cluster(statefip)
			sum `y' [aw=weight] if e(sample)==1
	}

**********************************************************
**Table A8: With state by month FE 
*********************************************************
	clear 
	use "`atus'"
	keep if year>=2011 & year<=2021
	keep if age>=21 & age!=.
	
	**BJS 
		rename groupvar Ei
		replace Ei=. if Ei==0
	**State month 
		egen statemonth=group(statefips month)
	**BJS FE 
		local bjs_controls2="month age covid  male period1_start statefips year statemonth"
	**Regression 
		foreach y in "timeplace_home" "timeplace_gym" "timeplace_grocerystore" "timeplace_restbar"  "timeplace_workplace" "timeplace_outdoors" "timeplace_compmissing"{
			**All, Full FE 
			dis "outcome `y', All"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight], fe(`bjs_controls2') cluster(statefips) autosample
			sum `y' [aw=weight] if e(sample)==1
	
			**Male, Full FE 
			dis "outcome `y', Male"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if male==1, fe(`bjs_controls2') cluster(statefips) autosample
			sum `y' [aw=weight] if e(sample)==1
						 
			**Female, Full FE 
			dis "outcome `y', Female"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if male==0, fe(`bjs_controls2') cluster(statefips) autosample
			sum `y' [aw=weight] if e(sample)==1
	}

******************************************************
**Table A11: Share of non-missing minutes 
*******************************************************
	clear 
	use "`atus'"
	keep if year>=2011 & year<=2021
	keep if age>=21 & age!=.	
	**BJS 
		rename groupvar Ei
		replace Ei=. if Ei==0
	**BJS FE 
		local bjs_controls1="month age covid  male period1_start statefips year"
	**Regression 
		foreach y in "share_home" "share_gym" "share_grocerystore" "share_restbar" "share_workplace" "share_outdoors" {
			**All, Full FE 
			dis "outcome `y', All"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight], fe(`bjs_controls1') cluster(statefips) autosample
			sum `y' [aw=weight] if e(sample)==1
	
			**Male, Full FE 
			dis "outcome `y', Male"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if male==1, fe(`bjs_controls1') cluster(statefips) autosample
			sum `y' [aw=weight] if e(sample)==1
						 
			**Female, Full FE 
			dis "outcome `y', Female"
			eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if male==0, fe(`bjs_controls1') cluster(statefips) autosample
			sum `y' [aw=weight] if e(sample)==1
	}

**************************************************
**Table A14: Border Analysis, Adjacent Counties
*************************************************

	clear 
	use "`atus'"
	**Keep relevant years
		keep if year>=2011 & year<=2021
	**Keep relevant age
		keep if age>=21 & age!=.
	**Keep states that do not have RML
		keep if (statefips==1|statefips==5|statefips==12|statefips==13|statefips==15|statefips==16|statefips==18|statefips==19|statefips==20|statefips==21|statefips==22|statefips==28|statefips==31|statefips==33|statefips==37|statefips==38|statefips==39|statefips==40|statefips==42|statefips==45|statefips==46|statefips==47|statefips==48|statefips==49|statefips==54|statefips==55|statefips==56)

	**Groupvar: Create a groupvar that is associated with the nearest RML implementation in the adjacent state
		drop groupvar 
		gen groupvar=0	
		gen hasneighbor=0

	*****************************
	**Neighbor states 
	*****************************
	*1. Alabama neighbors (AL): MS (none), FL (none), GA (none), TN (none)
	*2. Arkansas neighbors (AR): TX (none), MO	(2/3/23), OK	(none), LA	(none), MS	(none), TN (none)
	*3. Florida neighbors (FL): GA	(none), AL (none)
	*4. Georgia neighbors (GA): SC	(none), AL	(none), TN	(none), NC	(none), FL (none)
	*5. Hawaii neighbors (HI): No neighbors 
	*6. Iowa neighbors (IA): MN(start in 2023), SD(none), IL(1/1/2020), MO(2/3/23), NE(none), WI(none), Jan 2020
		replace groupvar=109 if statefips==19
		replace hasneighbor=1 if statefips==19
	*7.Idahoe neighbors(ID): WY	(none), UT	(none), WA	(7/8/14) (this), OR	(10/1/15), NV	(7/1/2017), MT (1/1/2022)
		replace groupvar=43 if statefips==16
		replace hasneighbor=1 if statefips==16
	*8.Indiana neighbors (IN): KY(none), MI(12/1/2019) , OH(none), IL(1/1/2020)
		replace groupvar=108 if statefips==18
		replace hasneighbor=1 if statefips==18
	*9. Kansas neighbors (KS): MO	(2/3/23), CO	(1/1/2014) (this), NE	(none), OK (none)
		replace groupvar=37 if statefips==20
		replace hasneighbor=1 if statefips==20
	**10.Kentucky neighbors (KY): IL(1/1/20), VA(none), OH(none), TN(none), MO(2/3/23), IN(none), WV(none)
		replace groupvar=109 if statefips==21
		replace hasneighbor=1 if statefips==21
	**11.Louisiana neighbors (LA): AR (none), TX	(none), MS (none)
	**12.Mississippi neighbors (MS): LA	(none), AL	(none), TN	(none), AR (none)
	**13.North Carolina neighbors (NC): SC	(none), VA	(none), TN	(none), GA (none)
	**14.North Dakota neighbors (ND): ND	(none), MN	(none), MT	(1/1/2022), SD (none)
	**15.Nebraska neighbors (NE): CO(1/1/2014), SD(none), MO(2/3/23), WY(none), IA(none), KS(none)
		replace groupvar=37 if statefips==31
		replace hasneighbor=1 if statefips==31
	*16.New Hamshire neighbors (NH): MA	(11/20/2018), VT	(10/1/2022), ME (10/9/2020)
		replace groupvar=85 if statefips==33
		replace hasneighbor=1 if statefips==33
	**17.Ohio neighbors (OH): KY(none), PA(none), WV(none), MI(12/1/2019), IN (none )
		replace groupvar=108 if statefips==39
		replace hasneighbor=1 if statefips==39
	*18.Oklahoma neighbors(OK): TX(none), MO(2/3/23), NM(4/1/2022), CO(1/1/2014), KS(none), AR(none)
		replace groupvar=37 if statefips==40
		replace hasneighbor=1 if statefips==40
	*19.Pennsylvania neighbors (PA): MD(7/1/2023), OH(none), NY(12/29/22), NJ(4/20/2022), WV(none), DE(2024)
	**20.South Carolina (SC): GA	(none), NC (none)
	**21.South Dakota (SD): MN(none), NE(none), WY(none), MT(1/1/2022), IA(none), ND(none)
	**22.Tennessee neighbors (TN): AR(none), VA(none), AL(none), MO(2/3/23), KY(none), MS(none), NC(none), GA (none)
	**23.Texas neighbors(TX): AR(none), OK(none), LA(none), NM(4/1/2022)
	*24.Utah neighbors(UT): NV(7/1/2017), WY(none), NM(4/1/2022), AZ(1/22/2021), ID(none), CO(1/1/2014) 
		replace groupvar=37 if statefips==49
		replace hasneighbor=1 if statefips==49
	*25.Wisconsin neighbors: MI	(12/1/2019), IL	(1/1/2020), MN	(none), IA (none)
		replace groupvar=108 if statefips==55
		replace hasneighbor=1 if statefips==55
	*26. west virginia neighbors(WV): MD	(7/1/2023), KY	(none), PA	(none), VA	(none), OH (none)
	*27. Wyoming neighbors: UT	(none), SD	(none), NE	(none), ID	(none), CO	(1/1/2014), MT (1/1/2022)
		replace groupvar=37 if statefips==56
		replace hasneighbor=1 if statefips==56

	** Borsuyak grouping (monthly)
		gen Ei=.
		replace Ei=groupvar if hasneighbor==1
		replace Ei=. if Ei==0
	*******************************************
	**Regressions
	*****************************************
	**Groups 
		egen statemonth=group(statefips month)
		egen stateyear=group(statefips year)
	**BJS FE 
		local bjs_controls2="month age covid  male period1_start statefips year statemonth"
		
	foreach y in "timeplace_home" "timeplace_gym" "timeplace_grocerystore" "timeplace_restbar"  "timeplace_workplace"  "timeplace_outdoors" {	 	
		**All, Full FE 
		eststo clear
		eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight], fe(`bjs_controls2') cluster(statefips) autosample
		sum `y' [aw=weight] if e(sample)==1
		
		**Male, Full FE 
		eststo clear
		eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if male==1, fe(`bjs_controls2') cluster(statefips) autosample
		sum `y' [aw=weight] if e(sample)==1
				
		**Female, Full FE 
		eststo clear
		eststo reg1: did_imputation  `y' statefips yearmonth Ei [aw=weight] if male==0, fe(`bjs_controls2') cluster(statefips) autosample
		sum `y' [aw=weight] if e(sample)==1
		}

**********************************************************
**Figure 3 
*********************************************************
	clear 
	use "`atus'"
	**Keep relevant years
		keep if year>=2011 & year<=2021
	**Keep relevant age
		keep if age>=21 & age!=.
	**Event study 	
	foreach y in "timeplace_home" "timeplace_gym" "timeplace_grocerystore" "timeplace_restbar"  "timeplace_workplace"  "timeplace_outdoors" {	
	did_imputation `y' statefips year rml_start [aw=weight], fe(month age covid male statefips year period1_start) horizons(0/4) pretrend(4) cluster(statefips) 
	event_plot
	}
